﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Photon.SocketServer;
using WorldOfSuperpowers_COMMON;

namespace WorldOfSuperpowers.Handler
{
    public abstract class BaseHandler
    {
        public OperationCode code;
        public void RegistOnMaster()
        {
            InitCode();
            MasterServer.log.Debug("添加code");
            MasterServer.handlerDic.Add(code, this);
        }

        public abstract void InitCode();
        public abstract void TranslateDic(Dictionary<byte, object> message,MasterClientPeer peer,SendParameters sendParameters);

        public virtual object GetValueFromDic(OperationCode code,Dictionary<byte,object> message)
        {
            object data = null;
            if (!message.TryGetValue((byte)code,out data))
            {
                MasterServer.log.Error("无法获取到有效信息");
            }
            return data;
        }
    }
}
